import java.util.Scanner;

public class Must2{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

        int number;
        while (true){
            System.out.printf("请输入数字 2: ");
            if (scanner.hasNextInt()){  // 检查输入是否为整数
                number = scanner.nextInt();
                if (number == 2){
                    break;  // 输入正确，退出循环
                }else {
                    System.out.println("错误：输入的不是 2!");
                }
            }else {
                System.out.println("错误：请输入整数！");
                scanner.next();  // 清除错误的输入
            }
        }

        System.out.println("输入正确！程序继续...");
        scanner.close();
    }
}